package secure;

/**
 * Created with IntelliJ IDEA.
 * ClassName: Practice
 * Package: create
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-08-12
 * Time: 21:51
 */

//多线程练习
public class Practice {
    //创建两个分线程 一个输出 100内的奇数 一个输出100内的偶数

    public static void main(String[] args) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 101; i++) {
                    if (i % 2 == 0){
                        System.out.println("偶数: " + i);
                    }
                }
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 101; i++) {
                    if (i % 2 != 0){
                        System.out.println("奇数: " + i);
                    }
                }
            }
        }).start();

        //匿名的方式创建
        new Thread(){
            @Override
            public void run() {
                System.out.println("匿名内部类");
            }
        }.start();

    }

}
